<div class="primary sidebar">
	<ul>
	<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
		<?php braille_search(); ?>
		<?php if (is_home() or is_search()) { ?>
		<?php if (get_option('braille_about') != '') { ?>
			<li class="about-text">
				<?php braille_info('about'); ?>
			</li>
		<?php } } elseif (is_single()) { ?>
		<?php rewind_posts(); ?>	
		<?php if ( have_posts() ) {

			get_currentuserinfo();
			global $user_level;

			the_post();
				
			$author_id = $post->post_author;
				
		?>
			<li class="about-text">
				<p><?php echo wptexturize(sprintf(__('You are currently reading the entry <strong>"%1$s"</strong> written by %2$s on %3$s at %4$s in %5$s.', 'braille'), get_the_title(), '<span class="entry-author author vcard"><a href="'. get_author_link(0, $author_id, $authordata->user_nicename) .'" class="url fn">'. get_the_author() .'</a></span>', get_the_time(__('F jS, Y', 'braille')),get_the_time(__('g:i a', 'braille')), braille_categories(', ', __(' and ', 'braille')))); ?></p>	
			</li>
		<?php } ?>
		<?php rewind_posts(); ?>
		<?php } elseif (is_category()) { ?>
			<li class="about-text">
				<p><?php echo wptexturize(sprintf(__('You are currently browsing the <strong>%s</strong> category.', 'braille'), single_cat_title('', false))); ?></p>
			</li>

		<?php } elseif (is_day()) { ?>
			<li class="about-text">
				<p><?php echo wptexturize(sprintf(__('You are currently browsing the archives for the day <strong>%s</strong>.', 'braille'), get_the_time(__('l, F jS, Y', 'braille')))); ?></p>
			</li>

		<?php } elseif (is_month()) { ?>
			<li class="about-text">
				<p><?php echo wptexturize(sprintf(__('You are currently browsing the archives for the month <strong>%s</strong>.', 'braille'), get_the_time(__('F, Y', 'braille')))); ?></p>
			</li>
		
		<?php } elseif (is_year()) { ?>
			<li class="about-text">
				<p><?php echo wptexturize(sprintf(__('You are currently browsing the archives for the year <strong>%s</strong>.', 'braille'), get_the_time('Y', 'braille'))); ?></p>
			</li>

		<?php } elseif (is_author()) { ?>
			<li class="about-text">
				<p><?php echo wptexturize(sprintf(__('Entries written by <strong>%s</strong>.', 'braille'), get_the_author())); ?></p>
				<p><?php the_author_description(); ?></p>
			</li>

		<?php } elseif (is_attachment()) { ?>
			<li class="about-text">
				<p><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo wptexturize(sprintf(__('Back to "%s"', 'braille'), get_the_title($post->post_parent))); ?></a></p>
			</li>
		<?php } ?>
		<?php if (is_page()) { 
			$current_page = $post->ID;
			
			while($current_page) {
				$page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
				$current_page = $page_query->post_parent;
			}
			
			$parent_id = $page_query->ID;
			$parent_title = $page_query->post_title;

			if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) 
		{ ?>
		<li>
			<h3><?php _e('Subpages'); ?></h3>
			<ul>
				<?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?>
			</ul>
		</li>
		<?php } } ?>
		<?php braille_admin_control(); ?>
		<?php if (!is_single()) braille_feed_links(); ?>
	<?php endif; ?>
	</ul>
</div>
<div class="clear-right"></div>
<div class="secondary sidebar">
	<ul>
	<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
		<?php if (!is_single() and !is_page()) braille_category_links(); ?>
		<?php if (!is_single() and !is_page()) braille_archive_links(); ?>
		<?php braille_meta_links(); ?>
	<?php endif; ?>
	</ul>
</div>